#import "BaseViewController.h"


@implementation OIBaseViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil
                         bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        UIImage* img = [UIImage imageNamed:@"white_logo"];
        self.navigationItem.titleView = [[UIImageView alloc] initWithImage:img];
        self.showNavigationBar = NO;
        self.popGestureRecognizerEnable = YES;
        self.hidesBottomBarWhenPushed = YES;
    }
    return self;
}



- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    if (self.pageName.length == 0 || !self.pageName){
        self.pageName = NSStringFromClass([self class]);
    }
  
    [self.navigationController setNavigationBarHidden:!self.showNavigationBar animated:animated];
    UIColor *color = kBack_Color_Default;
    UIImage *image = [UIImage imageWithColor:color];
    [self.navigationController.navigationBar setBackgroundImage:image
                                                 forBarPosition:UIBarPositionTopAttached
                                                    barMetrics:UIBarMetricsDefault];
    
    for (UIGestureRecognizer * pan in self.navigationController.view.gestureRecognizers) {
        if ([pan isKindOfClass:[UIPanGestureRecognizer class]]){
            pan.enabled = _popGestureRecognizerEnable;
        }
    }
    [self setNeedsStatusBarAppearanceUpdate];
}
//set status bar white color
- (void)viewDidLoad{
    [super viewDidLoad];
    self.navigationController.navigationBar.barStyle = UIBarStyleBlackTranslucent;
    
//    id target = self.
//    UIPanGestureRecognizer * pan = [[UIPanGestureRecognizer alloc]initWithTarget:self action:@selector(HandleNavigationTransition:)];
    
    
//    @weakify(self);
//    self.navigationController.interactivePopGestureRecognizer.delegate = weak_self;
//    if (self.navigationController && [self.navigationController.viewControllers count] == 1) {
//        self.navigationController.interactivePopGestureRecognizer.enabled = NO;
//    }else{
//        self.navigationController.interactivePopGestureRecognizer.enabled = YES;
//    }
}


- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    if (!self.pageName || self.pageName.length == 0){
        self.pageName = NSStringFromClass([self class]);
    }
}

//-(void)didFinishGetUMSocialDataInViewController:(UMSocialResponseEntity *)response{
//    [UMSocialHelper shareSucceess:response];
//}
//友盟的分享sdk分享结果改为block  可以直接处理
@end

@implementation OIRootBaseViewController

- (instancetype)initWithNibName:(NSString *)nibNameOrNil
                         bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self)
    {
        self.hidesBottomBarWhenPushed = NO;
        self.showNavigationBar = YES;
    }
    return self;
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self checkNewMsg];
}

-(void)checkNewMsg
{
    NSInteger lasttimeStamp = (int)[[NSUserDefaults standardUserDefaults] integerForKey:@"last_checkmsg_time"];
    NSInteger curtimeStamp = (int)[[NSDate date] timeIntervalSince1970];
    if(curtimeStamp - lasttimeStamp > 60 * 2) {
        [[NSUserDefaults standardUserDefaults] setInteger:curtimeStamp forKey:@"last_checkmsg_time"];
    }
}

@end
